package dz.salah.ouchenne.com;

import java.util.List;
import java.util.Vector;

import org.apache.ws.policy.AbstractAssertion;
import org.apache.ws.policy.Policy;
import org.apache.ws.policy.PrimitiveAssertion;

public class Offers {
Vector<String> Encryption;
Vector<String> DigitalSignature;
Vector<String> Protocol;

Offers(Policy P)
{
this.Encryption= new Vector<String>();
this.DigitalSignature= new Vector<String>();
this.Protocol= new Vector<String>();
List<AbstractAssertion> L=P.getTerms();
L=L.get(0).getTerms(); 
for(int i=0;i<L.size();i++)
{
  List<AbstractAssertion> K=L.get(i).getTerms();
	  for(int j=0;j<K.size();j++)
	   {
		   String s=((PrimitiveAssertion)K.get(j)).getName().toString();
		   s=s.substring(s.lastIndexOf('}')+1, s.length());
		   
		    
		   
		   if(s.equals("Encryption"))
		  {
		
			this.Encryption.add(((PrimitiveAssertion)K.get(j)).getStrValue());
            //System.out.println("Ajout de l'element : "+((PrimitiveAssertion)K.get(j)).getStrValue()+" dans le Vectuer Encryption");  
     		  
		  }  
		  else
		    if(s.equals("DigitalSignature"))
			 {
				
		    	this.DigitalSignature.add(((PrimitiveAssertion)K.get(j)).getStrValue());
		    	//System.out.println("Ajout de l'element : "+((PrimitiveAssertion)K.get(j)).getStrValue()+" dans le Vectuer DigitalSignature");
		    	
	     	 }	
			  else
				if(s.equals("Protocol"))
				{
				
					this.Protocol.add(((PrimitiveAssertion)K.get(j)).getStrValue());
		            //System.out.println("Ajout de l'element : "+((PrimitiveAssertion)K.get(j)).getStrValue()+" dans le Vectuer Protocol");	
				}else 
				{System.out.println("Syntax Errors at the Policy File : "+s);System.exit(0);}
					
			
	   }

	   }    


}

Vector<String> getEncryption()
{
return	this.Encryption;
}

Vector<String> getDigitalSignature()
{
return	this.DigitalSignature;
}

Vector<String> getProtocol()
{
return	this.Protocol;
}
}
